#include "ARPObject.h"

using namespace arp;

// ----------------------------------------------------------------------------
// ARPObject
// ----------------------------------------------------------------------------
ARPObject::ARPObject(void *owner)
{
	this->owner = owner;
	state = asClosed;
}

ARPObject::~ARPObject()
{
	close();
}

bool ARPObject::open()
{
	if (state != asClosed)
		return false;
	state = asOpening;
	if (doOpen())
	{
		state = asOpened;
		return true;
	}
	state = asClosed;
	return false;
}

bool ARPObject::close()
{
	if (state != asOpened)
		return false;
	state = asClosing;
	doClose();
	state = asClosed;
	return true;
}

bool ARPObject::active()
{
	return state == asOpened;
}